﻿<UserControl x:Class="ucDepartments"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:ATS" Width="auto">
    <UserControl.Resources>
        <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="3" />
            <Setter Property="Opacity" Value=".80" />
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="ContentSite" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStop Offset="0" Color="LightGray"/>
                                                <GradientStop Offset="1" Color="DarkGray"/>
                                            </LinearGradientBrush.GradientStops>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="BorderBrush" Value="Silver" />
                                <Setter Property="Opacity" Value="1"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true" />
                                    <Condition Property="Selector.IsSelectionActive" 
                                               Value="false" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" Value="LightGray" />
                                <Setter Property="BorderBrush" Value="DarkGray" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="Gray" />
                </Trigger>
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
                                                 From="1" To="1.125"/>
                                    <DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
                                                 From="1" To="1.125"/-->
                                <DoubleAnimation Duration="0:0:0.2"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="1.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
                                                 From="1.125" To="1"/>
                                    <DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
                                                 From="1.125" To="1"/-->
                                <DoubleAnimation Duration="0:0:0.2"
                                                 Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>


        <DataTemplate x:Key="listBoxTemplate">
            <Border BorderBrush="Blue"
                    BorderThickness="1"
                    CornerRadius="1"
                    Margin="1">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding DepartmentName}" 
                               Foreground="Green" 
                               FontWeight="Bold"
                                   Name="username" Margin="1"/>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0">
                        <Label Content ="Code : " 
                               Foreground="Black" HorizontalAlignment="Left"  VerticalAlignment="Center" />
                        <Label Content="{Binding DepartmentCode}" 
                               Foreground="Green" Name="categoryCode" HorizontalAlignment="Left"  VerticalAlignment="Center"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </DataTemplate>

    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Border Name="borderHeader" 
                Grid.Column="0" 
                BorderBrush="Gray" 
                BorderThickness="0,1,1,1" 
                CornerRadius="6,6,6,6">
            <Grid Name="gridListbox"  VerticalAlignment="Stretch" Height="auto">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal" 
                            Background="Aquamarine"                            
                            VerticalAlignment="Top"
                            Margin="2" Grid.Row="0">
                    <TextBox MinHeight="10" 
                             MinWidth="126"
                             Margin="2"
                             Name="searchBox"></TextBox>
                    <Button MinWidth="50"                            
                            Margin="2"
                            Name="searchButton">Find</Button>
                </StackPanel>

                <ListBox Name="listBoxDepartments"    
                         Grid.Row="1" 
                         
                         HorizontalContentAlignment="Stretch"
                         ItemContainerStyle="{DynamicResource ListBoxItem}" 
                         ItemTemplate="{StaticResource listBoxTemplate}" 
                         IsSynchronizedWithCurrentItem="True"
                         ItemsSource="{Binding}"
                         VerticalAlignment="Top"  Height="auto"></ListBox>

            </Grid>
        </Border>
        <Border Name="borderHeader1" 
                Grid.Column="1" 
                BorderBrush="Gray" 
                BorderThickness="0,1,1,1" 
                CornerRadius="6,6,6,6">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Border Name="borderHeader2" 
                Grid.Row="0"
                BorderBrush="Gray" 
                BorderThickness="0,1,1,1" 
                CornerRadius="6,6,6,6">
                    <my:ucActions x:Name="ucActions"  ></my:ucActions>
                </Border>

                <ScrollViewer Grid.Row="1" >
                    <StackPanel VerticalAlignment="Top">
                        <Grid Name="gridDepartmentDetails">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                                <RowDefinition Height="auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Label Margin="5" HorizontalAlignment="Left" FontWeight="bold" Grid.Row="0">Department</Label>
                            <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="1">Code</Label>
                            <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="2" Width="150" Name="textboxCode"></TextBox>
                            <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="3">Name</Label>
                            <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="4" Width="300" Name="textboxName"></TextBox>
                            <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="5">Description</Label>
                            <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="6" Width="300" Height="100" Name="textboxDescription"></TextBox>

                        </Grid>
                    </StackPanel>
                </ScrollViewer>
            </Grid>
        </Border>
    </Grid>

</UserControl>
